
# 环形链表
# 环之前为 a 环之后为 b

# kb + a = 2c
# kb = 2c - a
# c - a = b
# c = (k-1)b
# 2c = 2(k-1)b

class Solution:
    def hasCycle(self, head) -> bool:

        if not head or not head.next:
            return False

        A = head
        B = head
        A = A.next.next
        B = B.next
        if A == B:
            return True
        while A != B and A and A.next:

            A = A.next.next
            B = B.next
            if A == B:
                return True
        
        return False




